﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace QLDonDatHang
{
    public partial class Form_Dondathang : Form
    {
        Form DatHangMoi,timkiem;
        SqlConnection database = new SqlConnection(@"Data Source=DESKTOP-COHCEFP;Initial Catalog=QL_BANHANG_GIOCHA;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False");
        //dong tren la chuoi ket noi csdl

        public Form_Dondathang()
        {
            InitializeComponent();
        }
        //Ham tao ket noi csdl
        private void ketNoiCSDL()
        {
            database.Open();
            //mo csdl
            SqlCommand cmd = new SqlCommand("select * from QL_DONDATHANG", database);
            //Truy van lay het du lieu trong ban QL_DONDATHANG
            cmd.CommandType = CommandType.Text;
            SqlDataAdapter da = new SqlDataAdapter(cmd);//van chuyen du lieu ve

            DataTable table = new DataTable();//tao mot bang du lieu ao
            da.Fill(table);// do du lieu vao table
            database.Close();

            dataGridView1.DataSource = table;

        }


        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
        }
        private void Form_Dondathang_Load(object sender, EventArgs e)
        {
            
            ketNoiCSDL();
        }

        private void button3_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Hide();
            DatHangMoi = new Form_DatHangMoi();
            DatHangMoi.ShowDialog();    
        }

        private void button4_Click(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {   
            //timkiem = new Form_TimKiem();
            timkiem.ShowDialog();
            this.Hide();
        }
    }
}
